import re
import codecs
def get_os_ver():
    catout = codecs.open("/etc/os-release","rb","gbk","ignore") #读取文件
    txt = catout.read() #获取文件内容

    Search_rele = re.compile(r'''VERSION_ID=\"\d*''') #定义正则表达式
    Txt_search = Search_rele.search(txt)    #开始使用正则匹配
    print("搜寻结果: [ %s ]" %Txt_search)

    os_info = (Txt_search.group())
    print('打印搜寻结果实际内容 [ %s ] ' %os_info)

    os_ver = str.replace(os_info, 'VERSION_ID=\"', ' ')
    print("当前系统版本号: [ %s ]" %os_ver)

c = get_os_ver()